<template>
	<div class="hy-container">
		<HyTable :searchDefault="searchDefault" @sendState="getState" :tableConfig="tableConfig" :tableColumns="tableColumns" ref="hyTableRef">
			<template #tableHeader>
				<HyTitle title="我的信息" />
				<div class="my-5">
					<el-button v-if="addButtonShow" type="primary" icon="Plus" @click="handleAdd">新增</el-button>
				</div>
			</template>
			<template #expertTypeArr="{ row }">
				{{ formatteCascader(row.expertTypeArr || [], expert_type) }}
			</template>
			<template #operation>
				<el-table-column fixed="right" width="75">
					<template #default="{ row }">
						<el-button text type="primary" @click="handleView(row)">查看</el-button>
					</template>
				</el-table-column>
			</template>
		</HyTable>
	</div>
</template>

<script lang="ts" setup>
import HyTable from '/@/components/HyTable/index.vue';
import { expertInfoMinePageApi } from '/@/api/expertDatabase/expert';
import { useUserInfo } from '/@/stores/userInfo';
import { formatteCascader } from '/@/utils/hyFunc';
import HyTitle from '/@/components/HyTitle/index.vue';
import { useTreeDict } from '/@/hooks/dict';
import { useOperate } from '../hooks/useOperate';
const { expert_type } = useTreeDict('expert_type');
const tableConfig = {
	title: '我的信息',
	request: expertInfoMinePageApi,
};
const tableColumns = computed(() => {
	const { columns } = useOperate();
	return columns;
});

const searchDefault = ref({
	blacklist: '0',
	expertTel: useUserInfo().userInfos.user.phone,
});
const handleAdd = () => {
	const { routerGo } = useOperate({ operateType: 'add', expertInfoId: '', status: '0' });
	routerGo();
};

const handleView = (row: any) => {
	const { routerGo } = useOperate({ operateType: 'view', expertInfoId: row.expertInfoId, status: '' });
	routerGo();
};
const addButtonShow = ref(true);
const getState = (value: any) => {
	if (value.total > 0) {
		addButtonShow.value = false;
	} else {
		addButtonShow.value = true;
	}
};
</script>

<style scoped lang="scss"></style>
